Skip to content

Commit

Permalink
#658 : creating dpa
Browse files Browse the repository at this point in the history
  • Loading branch information
arakov committed Aug 4, 2024
1 parent 510ae41 commit ff365dc
Show file tree
Hide file tree
Showing 29 changed files with 407 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/msbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
BUILD_CONFIGURATION: Release

BUILD_TAG: 6.2.3
BUILD_TAG: 6.2.4

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.2.2
6.2.4
2 changes: 1 addition & 1 deletion build/aarch64/build_package_arm64.script
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
RELEASE=elena-6.2.3.aarch64-linux
RELEASE=elena-6.2.4.aarch64-linux

mkdir -p /usr/share/elena
mkdir -p /etc/elena/
Expand Down
2 changes: 1 addition & 1 deletion build/aarch64/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: elena-lang
Version: 6.2.3
Version: 6.2.4
Architecture: aarch64
Maintainer: Alex Rakov <[email protected]>
Depends: libc6 (>= 2.1)
Expand Down
2 changes: 1 addition & 1 deletion build/amd64/build_package_amd64.script
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
RELEASE=elena-6.2.3.amd64-linux
RELEASE=elena-6.2.4.amd64-linux

mkdir -p /usr/share/elena
mkdir -p /etc/elena/
Expand Down
2 changes: 1 addition & 1 deletion build/amd64/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: elena-lang
Version: 6.2.3
Version: 6.2.4
Architecture: amd64
Maintainer: Alex Rakov <[email protected]>
Depends: libc6 (>= 2.1)
Expand Down
2 changes: 1 addition & 1 deletion build/elena_inno.iss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{3CAA69D3-0F98-44B1-A73E-E864BA51D5BD}
AppName=ELENA Programming Language
AppVersion=6.2.3
AppVersion=6.2.4
;AppVerName=ELENA Programming Language 6.2.0
AppPublisher=Alexey Rakov
AppPublisherURL=http://github.com/ELENA-LANG/elena-lang
Expand Down
2 changes: 1 addition & 1 deletion build/i386/build_package_i386.script
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
RELEASE=elena-6.2.3.i386-linux
RELEASE=elena-6.2.4.i386-linux

mkdir -p /usr/share/elena
mkdir -p /etc/elena/
Expand Down
2 changes: 1 addition & 1 deletion build/i386/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: elena-lang
Version: 6.2.3
Version: 6.2.4
Architecture: i386
Maintainer: Alex Rakov <[email protected]>
Depends: libc6 (>= 2.1)
Expand Down
2 changes: 1 addition & 1 deletion build/ppc64le/build_package_ppc64le.script
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
RELEASE=elena-6.2.3.ppc64le-linux
RELEASE=elena-6.2.4.ppc64le-linux

mkdir -p /usr/share/elena
mkdir -p /etc/elena/
Expand Down
2 changes: 1 addition & 1 deletion build/ppc64le/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: elena-lang
Version: 6.2.3
Version: 6.2.4
Architecture: ppc64le
Maintainer: Alex Rakov <[email protected]>
Depends: libc6 (>= 2.1)
Expand Down
28 changes: 28 additions & 0 deletions doc/features
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,31 @@ public program()
----------------------------------------------------------------------------

var s := var s := $"a_{ 1 }_b_{ 2 }_c";

----------------------------------------------------------------------------
user-defined literals
----------------------------------------------------------------------------

import extensions;

sealed struct OctalNumber
{
int value;

int cast() = value;

constructor(int n)
{
value := n;
}

cast o(string s)
{
value := s.toInt(8);
}
}

public program()
{
var n := 12o;
}
44 changes: 43 additions & 1 deletion doc/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ In development:
dev:
- upndown (connector)
- async programming
- chat: add mutex (see dpa_queue)
gen:
- lpad
maint:
Expand All @@ -21,7 +22,6 @@ In development:
- User-defined string literals
--------------------------------------
- #658 : connect with ldbg from VSCode
--------------------------------------

### EPIC: elena 6.4 ###

Expand All @@ -34,3 +34,45 @@ In development:
prom:
--------------------------------------
--------------------------------------

=== Iteration 32 ===
--------------------------------------
dev:
gen:
maint:
port:
prom:
--------------------------------------
--------------------------------------

=== Iteration 33 ===
--------------------------------------
dev:
gen:
maint:
port:
prom:
--------------------------------------
--------------------------------------

=== Iteration 34 ===
--------------------------------------
dev:
gen:
maint:
port:
prom:
--------------------------------------
--------------------------------------

### EPIC: elena 6.5 ###

=== Iteration 35 ===
--------------------------------------
dev:
gen:
maint:
port:
prom:
--------------------------------------
--------------------------------------
67 changes: 67 additions & 0 deletions elenasrc3/dpa/dpa_queue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//---------------------------------------------------------------------------
// E L E N A P r o j e c t: ELENA Debugger Adapater
//
// This file contains the DPA queue declarations
//
// (C)2024, by Aleksey Rakov
//---------------------------------------------------------------------------

#ifndef DPA_QUEUE_H
#define DPA_QUEUE_H

#include <queue>
#include <condition_variable>
#include <mutex>
#include <optional>

namespace dpa
{
// --- ContentReader ---
template <typename T>
class ThreadQueue
{
bool _closed = false;
std::queue<T> _queue;
std::condition_variable _cv;
std::mutex _mutex;

public:
void close();

void put(const T& in);
std::optional<T> take();
};

template <typename T>
void ThreadQueue<T> :: close()
{
std::unique_lock<std::mutex> lock(_mutex);
_closed = true;
_cv.notify_all();
}

template <typename T>
void ThreadQueue<T> :: put(const T& in)
{
std::unique_lock<std::mutex> lock(_mutex);
auto notify = _queue.size() == 0 && !_closed;
_queue.push(in);
if (notify)
_cv.notify_all();
}

template <typename T>
std::optional<T> ThreadQueue<T> :: take()
{
std::unique_lock<std::mutex> lock(_mutex);
_cv.wait(lock, [&] { return _queue.size() > 0 || _closed; });
if (_queue.size() == 0) {
return std::optional<T>();
}
auto out = std::move(_queue.front());
_queue.pop();
return std::optional<T>(std::move(out));
}
}

#endif
38 changes: 38 additions & 0 deletions elenasrc3/dpa/dpa_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,43 @@ Session :: Session()

Session :: ~Session()
{
_inbox.close();
if (_recvThread.joinable()) {
_recvThread.join();
}
if (_dispatchThread.joinable()) {
_dispatchThread.join();
}
_reader.close();
}

void Session :: connect()
{
_reader = ContentReader();
}

Payload Session :: getPayload()
{
return {};
}

void Session :: start(const ClosedHandler& onClose)
{
_recvThread = std::thread([this/*, onClose*/] {
while (_reader.isOpen()) {
if (auto payload = getPayload()) {
_inbox.put(std::move(payload));
}
}
//if (onClose) {
// onClose();
//}
});

_dispatchThread = std::thread([this] {
while (auto payload = _inbox.take()) {
payload.value()();
}
});

}
28 changes: 28 additions & 0 deletions elenasrc3/dpa/dpa_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,40 @@
#ifndef DPA_SESSION_H
#define DPA_SESSION_H

#include <functional>
#include <thread>

#include "dpa_stream.h"
#include "dpa_queue.h"

namespace dpa
{
using Payload = std::function<void()>;
using PayloadQueue = ThreadQueue<Payload>;

using ClosedHandler = std::function<void()>;

//using RequestHandler =
// std::function<void(const void* request)>;

// --- Session ---
class Session
{
ContentReader _reader;
PayloadQueue _inbox;

std::thread _recvThread;
std::thread _dispatchThread;

Payload getPayload();

public:
//virtual void registerHandler(const TypeInfo* typeinfo,
// const RequestHandler& handler);

void connect();
void start(const ClosedHandler& onClose = {});

Session();
virtual ~Session();
};
Expand Down
26 changes: 26 additions & 0 deletions elenasrc3/dpa/dpa_stream.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//---------------------------------------------------------------------------
// E L E N A P r o j e c t: ELENA Debugger Adapater
//
// This file contains the DPA I/O class implementations
//
// (C)2024, by Aleksey Rakov
//---------------------------------------------------------------------------

#include "dpa_stream.h"

using namespace dpa;

ContentReader :: ~ContentReader()
{

}

bool ContentReader :: isOpen()
{
return false;
}

void ContentReader :: close()
{

}
31 changes: 31 additions & 0 deletions elenasrc3/dpa/dpa_stream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//---------------------------------------------------------------------------
// E L E N A P r o j e c t: ELENA Debugger Adapater
//
// This file contains the DPA I/O class declarations
//
// (C)2024, by Aleksey Rakov
//---------------------------------------------------------------------------

#ifndef DPA_STREAM_H
#define DPA_STREAM_H

namespace dpa
{
//using RequestHandler =
// std::function<void(const void* request)>;

// --- ContentReader ---
class ContentReader
{

public:
bool isOpen();

void close();

ContentReader() = default;
virtual ~ContentReader();
};
}

#endif
Loading

0 comments on commit ff365dc

Please sign in to comment.