// Get the stream that is associated with a file descriptor, // together with a buffer that can be used for reads and writes. // Returns "null" if there is no stream associated. public static Stream GetStreamAndBuffer(int fd, out byte[] buffer) { lock (typeof(FileTable)) { if (fd >= 0 && fd < MaxDescriptors) { StreamRef sref = fds[fd]; if (sref != null) { if (sref.buffer == null) { sref.buffer = new byte [1024]; } buffer = sref.buffer; return(sref.stream); } else { buffer = null; return(null); } } else { buffer = null; return(null); } } }
public StreamItemBatch(StreamRef <TItem> stream, IList <SequentialItem <TItem> > items) : base(stream) { // ReSharper disable PossibleMultipleEnumeration Requires.NotNull(items, nameof(items)); Items = items; // ReSharper restore PossibleMultipleEnumeration }
private async Task CreateStorageAndProjectionStreams() { streamProjectionAggregate = System.StreamOf("SMSProvider", $"{Self.Path.Interface}"); streamProjectionDomain = System.StreamOf("SMSProvider", $"{Self.Path}"); snapshotBlobStream = await snapshotStore.ProvisonSnapshotStream(SnapshotStreamName()); eventTableStoreStream = await eventTableStore.ProvisonEventStream(StreamName()); }
public void Equatable_by_path() { var path = StreamPath.From("sms", "42"); var ref1 = new StreamRef(path); var ref2 = new StreamRef(path); Assert.True(ref1 == ref2); Assert.True(ref1.Equals(ref2)); }
public void Equatable_by_path() { var path = StreamPath.From("sms", "42"); var ref1 = new StreamRef(path, null); var ref2 = new StreamRef(path, null); Assert.True(ref1 == ref2); Assert.True(ref1.Equals(ref2)); }
// Allocate a new file descriptor, with no stream association. public static int AllocFD() { lock (typeof(FileTable)) { int newFD = NewFD(); if (newFD != -1) { fds[newFD] = new StreamRef(null); } return(newFD); } }
public override Task <object> Receive(object message) { switch (message) { case Activate _: stream = System.StreamOf("sms", $"{GetType().Name}-{Id}"); return(Result(Done)); case Command cmd: return(HandleCommand(cmd)); case Query query: return(HandleQuery(query)); default: return(base.Receive(message)); } }
// Duplicate a file descriptor, starting at a particular position. public static int DupAfter(int fd, int after) { lock (typeof(FileTable)) { if (fd < 0 || fd >= MaxDescriptors || fds[fd] == null) { return(-2); } int newFd = NewFD(after); if (newFd == -1) { return(-1); } StreamRef sref = fds[fd]; ++(sref.count); fds[newFd] = sref; return(newFd); } }
public override async Task <object> Receive(object message) { switch (message) { case Activate _: { // state is automatically loaded by storage provider // before Activate message is sent to the actor var state = State.Current ?? nameof(Initial); behavior.Initial(state); // grab reference to notifications stream notifications = System.StreamOf <JobEvent>("notifications", "copier"); break; } } // route all received messages via behavior return(await behavior.Receive(message)); }
// Set a file descriptor to a specific stream. The previous // association is lost, so it should only be used on a slot // that is known to be empty. public static void SetFileDescriptor(int fd, Stream stream) { lock(typeof(FileTable)) { StreamRef[] table = fds; StreamRef sref; if(fd >= 0 && fd < MaxDescriptors) { if((sref = table[fd]) == null) { table[fd] = new StreamRef(stream); } else { sref.stream = stream; sref.count = 1; sref.buffer = null; } } } }
// Set a file descriptor to a specific stream. The previous // association is lost, so it should only be used on a slot // that is known to be empty. public static void SetFileDescriptor(int fd, Stream stream) { lock (typeof(FileTable)) { StreamRef[] table = fds; StreamRef sref; if (fd >= 0 && fd < MaxDescriptors) { if ((sref = table[fd]) == null) { table[fd] = new StreamRef(stream); } else { sref.stream = stream; sref.count = 1; sref.buffer = null; } } } }
// Get the stream that is associated with a file descriptor. // Returns "null" if there is no stream associated. public static Stream GetStream(int fd) { lock (typeof(FileTable)) { if (fd >= 0 && fd < MaxDescriptors) { StreamRef sref = fds[fd]; if (sref != null) { return(sref.stream); } else { return(null); } } else { return(null); } } }
// Duplicate a file descriptor and replace another one. // Returns -1 if either of the descriptors are invalid. public static int Dup2(int oldfd, int newfd) { Stream streamToClose = null; lock (typeof(FileTable)) { StreamRef[] table = fds; if (oldfd < 0 || oldfd >= MaxDescriptors || table[oldfd] == null) { return(-1); } if (newfd < 0 || newfd >= MaxDescriptors) { return(-1); } StreamRef sref = table[oldfd]; if (sref == table[newfd]) { // The new stream is already the same as the old. return(newfd); } if (table[newfd] != null) { if (--(table[newfd].count) == 0) { streamToClose = table[newfd].stream; } } table[newfd] = sref; ++(sref.count); } if (streamToClose != null) { streamToClose.Close(); } return(newfd); }
async Task Publish(StreamRef <object> stream, object item) { var producer = system.ActorOf <ITestProducerActor>("foo"); await producer.Tell(new Publish(stream, item)); }
public static StreamRefSurrogate From(StreamRef @ref) => new StreamRefSurrogate { S = @ref.Path };
public ChatClient(IActorSystem system, string user, string room) { this.user = system.ActorOf<ChatUser>(user); this.room = system.StreamOf("sms", room); }
// Allocate a new file descriptor, with no stream association. public static int AllocFD() { lock(typeof(FileTable)) { int newFD = NewFD(); if(newFD != -1) { fds[newFD] = new StreamRef(null); } return newFD; } }
public StreamRef Original() => StreamRef.Deserialize(StreamPath.Deserialize(S));
public static StreamRefSurrogate From <TItem>(StreamRef <TItem> @ref) => new StreamRefSurrogate { S = @ref.Path };
public ChatClient(IActorSystem system, string user, string room) { this.user = system.ActorOf <ChatUser>(user); this.room = system.StreamOf <SimpleMessageStreamProvider>(room); }
private static Coder AdjustCoderForEncryption(Coder coder, StreamRef adjustedInputStream) { if (coder.InputStreams.Length != 1 || !(coder.InputStreams[0] is InputStreamRef) || ((InputStreamRef)coder.InputStreams[0]).PackedStreamIndex != 0) throw new NotSupportedException(); return new Coder { MethodId = coder.MethodId, Settings = coder.Settings, InputStreams = new[] { adjustedInputStream }, OutputStreams = coder.OutputStreams, }; }
public override Task OnActivate() { stream = System.StreamOf("sms", $"{GetType().Name}-{Id}"); return(base.OnActivate()); }
public StreamItem(StreamRef <TItem> stream, TItem item, StreamSequenceToken token = null) : base(stream) { Item = item; Token = token; }
public ChatClient(IActorSystem system, string user, string room) { this.user = system.ActorOf<ChatUser>(user); this.room = system.StreamOf<SimpleMessageStreamProvider>(room); }
public Publish(StreamRef <object> stream, object item) { Stream = stream; Item = item; }
public Push(StreamRef stream, object item) { Stream = stream; Item = item; }
public ChatClient(IActorSystem system, string user, string room) { this.user = system.ActorOf <ChatUser>(user); this.room = system.StreamOf("sms", room); }
async Task On(Activate _) { stream = System.StreamOf <Item>("sms", "test"); await stream.Subscribe(this); }
public override async Task OnActivate() { stream = System.StreamOf("sms", "test"); await stream.Subscribe(this); }